package com.kede.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.kede.ienum.SourceChannelEnum;
import com.kede.ienum.order.OrderStatusEnum;
import com.kede.typehanlder.SourceChannelEnumTypeHanlder;
import com.kede.typehanlder.order.OrderStatusEnumTypeHanlder;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 订单-商品表
 * @TableName sy_leescore_order_goods
 */
@TableName(value ="sy_leescore_order_goods")
@Data
@Builder
public class LeescoreOrderGoodsDomain implements Serializable {
    /**
     * 
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 订单ID
     */
    @TableField(value = "order_id")
    private Integer orderId;

    /**
     * 商品ID
     */
    @TableField(value = "goods_id")
    private Integer goodsId;

    /**
     * 购买数量
     */
    @TableField(value = "buy_num")
    private Integer buyNum;

    /**
     * 积分价格
     */
    @TableField(value = "score")
    private BigDecimal score;

    /**
     * 货币价格
     */
    @TableField(value = "money")
    private BigDecimal money;

    /**
     * 商品名称
     */
    @TableField(value = "goods_name")
    private String goodsName;

    /**
     * 商品缩略图
     */
    @TableField(value = "goods_thumb")
    private String goodsThumb;

    /**
     * 创建时间
     */
    @TableField(value = "createtime",fill = FieldFill.INSERT)
    private Integer createtime;

    /**
     * 订单状态:
     */
    @TableField(value = "order_status",typeHandler = OrderStatusEnumTypeHanlder.class)
    private OrderStatusEnum orderStatus;

    /**
     * 物流单号
     */
    @TableField(value = "logis_no")
    private String logisNo;

    /**
     * 物流名称
     */
    @TableField(value = "logis_name")
    private String logisName;

    /**
     * 快递公司编号
     */
    @TableField(value = "cp_code")
    private String cpCode;

    /**
     * 来源渠道/领取方式 1线上  2线下
     */
    @TableField(value = "source_channel",typeHandler = SourceChannelEnumTypeHanlder.class)
    private SourceChannelEnum sourceChannel;

    /**
     * 商品的选品说明
     **/
    @TableField(value = "type_info")
    private String typeInfo;

    /**
     * 下单的用户id  便于统计用户购买的数量
     */
    @TableField(value = "user_id")
    private Integer userId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        LeescoreOrderGoodsDomain other = (LeescoreOrderGoodsDomain) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
            && (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
            && (this.getBuyNum() == null ? other.getBuyNum() == null : this.getBuyNum().equals(other.getBuyNum()))
            && (this.getScore() == null ? other.getScore() == null : this.getScore().equals(other.getScore()))
            && (this.getMoney() == null ? other.getMoney() == null : this.getMoney().equals(other.getMoney()))
            && (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName()))
            && (this.getGoodsThumb() == null ? other.getGoodsThumb() == null : this.getGoodsThumb().equals(other.getGoodsThumb()))
            && (this.getCreatetime() == null ? other.getCreatetime() == null : this.getCreatetime().equals(other.getCreatetime()))
            && (this.getOrderStatus() == null ? other.getOrderStatus() == null : this.getOrderStatus().equals(other.getOrderStatus()))
            && (this.getLogisNo() == null ? other.getLogisNo() == null : this.getLogisNo().equals(other.getLogisNo()))
            && (this.getLogisName() == null ? other.getLogisName() == null : this.getLogisName().equals(other.getLogisName()))
            && (this.getCpCode() == null ? other.getCpCode() == null : this.getCpCode().equals(other.getCpCode()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
        result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
        result = prime * result + ((getBuyNum() == null) ? 0 : getBuyNum().hashCode());
        result = prime * result + ((getScore() == null) ? 0 : getScore().hashCode());
        result = prime * result + ((getMoney() == null) ? 0 : getMoney().hashCode());
        result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode());
        result = prime * result + ((getGoodsThumb() == null) ? 0 : getGoodsThumb().hashCode());
        result = prime * result + ((getCreatetime() == null) ? 0 : getCreatetime().hashCode());
        result = prime * result + ((getOrderStatus() == null) ? 0 : getOrderStatus().hashCode());
        result = prime * result + ((getLogisNo() == null) ? 0 : getLogisNo().hashCode());
        result = prime * result + ((getLogisName() == null) ? 0 : getLogisName().hashCode());
        result = prime * result + ((getCpCode() == null) ? 0 : getCpCode().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", orderId=").append(orderId);
        sb.append(", goodsId=").append(goodsId);
        sb.append(", buyNum=").append(buyNum);
        sb.append(", score=").append(score);
        sb.append(", money=").append(money);
        sb.append(", goodsName=").append(goodsName);
        sb.append(", goodsThumb=").append(goodsThumb);
        sb.append(", createtime=").append(createtime);
        sb.append(", orderStatus=").append(orderStatus);
        sb.append(", logisNo=").append(logisNo);
        sb.append(", logisName=").append(logisName);
        sb.append(", cpCode=").append(cpCode);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}